package com.clouds.wms.bean;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import com.clouds.wms.util.SysParams;

/**
 * 员工信息
 * @author liuchen
 */
public class Cmsmd implements Serializable {
	private static final long serialVersionUID = 1L;

	private String mdaa; // 员工编号【Staff】
	private String mdab; // 密码【password】
	private String mdac; // 姓名【Name】
	private String mdad; // 部门【Department】
	private String mdadStr; // 部门名称
	private int mdae; // 性别【Gender】 1.男2.女
	private long mdaf; // 员工权限【Staffs Authority】
	private long[] mdafs; // 员工权限【Staffs Authority】
	public String getMdaa() {
		return mdaa;
	}
	public void setMdaa(String mdaa) {
		this.mdaa = mdaa;
	}
	public String getMdab() {
		return mdab;
	}
	public void setMdab(String mdab) {
		this.mdab = mdab;
	}
	public String getMdac() {
		return mdac;
	}
	public void setMdac(String mdac) {
		this.mdac = mdac;
	}
	public String getMdad() {
		return mdad;
	}
	public void setMdad(String mdad) {
		this.mdad = mdad;
	}
	public String getMdadStr() {
		return mdadStr;
	}
	public void setMdadStr(String mdadStr) {
		this.mdadStr = mdadStr;
	}
	public int getMdae() {
		return mdae;
	}
	public void setMdae(int mdae) {
		this.mdae = mdae;
	}
	
	
	public long getMdaf() {
		return mdaf;
	}
	public void setMdaf(long mdaf) {
		this.mdaf = mdaf;
		this.mdafs = getMdafs(mdaf);
	}
	public long[] getMdafs() {
		return mdafs;
	}
	private long getMdaf(long[] mdafs) {
		long l = 0;
		for (int i = 0; i < mdafs.length; i++) {
			l |= (1L << (mdafs[i] - 1));
		}
		return new Long(l);
	}

	private long[] getMdafs(long mdaf) {
    	List<Long> temp = new ArrayList<Long>();
    	for (int i = 1; i <= SysParams.STAFF_AUTHORITY_COUNT; i++) {
    		long x1 = 1L << (i - 1);
    		long x2 = mdaf & x1;
    		if(x2 > 0) {
    			temp.add(new Long(i));
    		}
    	}
    	long[] result = new long[temp.size()];
    	for(int i = 0; i < result.length; i++) {
    		result[i] = temp.get(i);
    	}
    	return result;
	}
	public void setMdafs(long[] mdafs) {
		this.mdafs = mdafs;
		this.mdaf = getMdaf(mdafs);
	}
	
}
